home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
misc
/
dspice0s
/
shlsrt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-21
|
2KB
|
95 lines
/* shlsrt.f -- translated by f2c (version of 3 February 1990 3:36:42).
You must link the resulting object file with the libraries:
-lF77 -lI77 -lm -lc (in that order)
*/
#include "f2c.h"
/*< subroutine shlsrt(a,n) >*/
/* Subroutine */ int shlsrt_(a, n)
doublereal *a;
integer *n;
{
static integer h, i, j;
static doublereal ak, ar;
/* Parameter adjustments */
--a;
/* Function Body */
/*< implicit double precision (a-h,o-z) >*/
/* this routine sorts the array a using a shell sort algorithm. */
/*< dimension a(n) >*/
/*< integer h >*/
/* ... compute best starting step size */
/*< h=1 >*/
h = 1;
/*< 10 h=3*h+1 >*/
L10:
h = h * 3 + 1;
/*< if (h.lt.n) go to 10 >*/
if (h < *n) {
goto L10;
}
/* ... back off two times */
/*< h=(h-1)/3 >*/
h = (h - 1) / 3;
/*< h=(h-1)/3 >*/
h = (h - 1) / 3;
/*< h=max0(h,1) >*/
h = max(h,1);
/* shell sort */
/*< 20 j=h+1 >*/
L20:
j = h + 1;
/*< go to 60 >*/
goto L60;
/*< 30 i=j-h >*/
L30:
i = j - h;
/* ... ak = record key; ar = record */
/*< ak=a(j) >*/
ak = a[j];
/*< ar=ak >*/
ar = ak;
/*< 40 if (ak.ge.a(i)) go to 50 >*/
L40:
if (ak >= a[i]) {
goto L50;
}
/*< a(i+h)=a(i) >*/
a[i + h] = a[i];
/*< i=i-h >*/
i -= h;
/*< if (i.ge.1) go to 40 >*/
if (i >= 1) {
goto L40;
}
/*< 50 a(i+h)=ar >*/
L50:
a[i + h] = ar;
/*< j=j+1 >*/
++j;
/*< 60 if (j.le.n) go to 30 >*/
L60:
if (j <= *n) {
goto L30;
}
/*< h=(h-1)/3 >*/
h = (h - 1) / 3;
/*< if (h.ne.0) go to 20 >*/
if (h != 0) {
goto L20;
}
/*< return >*/
return 0;
/*< end >*/
} /* shlsrt_ */